home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- char *logfile, line[256];
- int maxlen = 0;
- FILE *fp, *tp;
-
- if(argc > 1) {
- logfile = argv[1];
- } else {
- logfile = "nos.log";
- }
-
- if((fp = fopen(logfile,"rt")) == 0) {
- fprintf(stderr,"%s can't open %s: %s\n\r",argv[0],logfile,sys_errlist[errno]);
- exit(1);
- }
-
- if((tp = fopen("log.new","wt")) == 0) {
- fprintf(stderr,"%s can't open log.new: %s\n\r",argv[0],sys_errlist[errno]);
- fclose(fp);
- exit(1);
- }
-
- while(fgets(line,sizeof(line),fp),!feof(fp)) {
- if(strlen(line) > maxlen)
- maxlen = strlen(line);
- if(strstr(line,"Shutdown") == 0 && strstr(line,"Startup") == 0)
- fputs(line,tp);
- }
- fclose(fp);
- fclose(tp);
- fprintf(stdout,"\n\rMax. line length %d\n\r",maxlen);
- return;
- }